﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="users.aspx.cs" Inherits="Skyworth.CRM.Web.SystemManagement.users" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>销售管理平台 | 用户管理</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <%--[if IE]>
     <link href="../themes/css/ieHack.css" rel="stylesheet" type="text/css" />
    <![endif]--%>
    <link href="../themes/<%= Request.Cookies["dwz_theme"]!=null? Request.Cookies["dwz_theme"].Value:"default" %>/style.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/core.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/pages.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/wbox.css" rel="stylesheet" type="text/css" />
    <link href="../themes/css/Messagebox.css" rel="stylesheet" type="text/css" />
    <script src="../javascripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="../javascripts/MessageBox.js" type="text/javascript"></script>
    <script src="../javascripts/jquery.tablesorter.min.js" type="text/javascript"></script>
    <script src="../javascripts/dwz.pagination.js" type="text/javascript"></script>
    <script src="../javascripts/wbox.js" type="text/javascript"></script>
     <style>
     .linkDisabled {
            color: Gray;
     }
     </style> 
    <script type="text/javascript">
        function Delete() {
            if ($(this).attr("disabled") != "disabled") {
                var userId = $("#selectedID").val();
                if (parseInt(userId) > 0) {
                    $.Messager.Confirm({ Title: '系统警告', Message: '你确定要删除该角色信息吗?', Icon: IconType.Question,
                        Oncallback: function(IsYes, siteMapId) {
                            if (IsYes) { $("#btnhidDelete").trigger("click"); }
                        }
                    })
                }
                else {
                    $.Messager.Alert({ Title: '系统消息', Message: "请选择要删除的角色！", Icon: IconType.Warning });
                    return false;
                }
                return false;
            }
        }
        $(document).ready(function() {
            $(".tableList table.list").tablesorter({ headers: { 0: { sorter: false}} });
            $("ul.toolBar li").hover(function() { $(this).addClass("hover"); },
                                                function() { $(this).removeClass("hover"); }
                     );
            $("#btnDelete").live('click', Delete);         
            //绑定表格行事件         
            $(".tableList table.list tbody tr:nth-child(even)").attr('class', "trbg");
            $(".tableList table.list tbody tr").hover(function() { $(this).addClass("hover"); },
                                                function() { $(this).removeClass("hover"); }).click(function() {
                                                    $(this).addClass("selected")
                                                    $(this).siblings().removeClass("selected");
                                                    $("#selectedID").val($(this).attr("rel"));
                                                    if (parseInt($(this).children("td").eq(6).text()) == 0 || parseInt($(this).children("td").eq(7).text()) > 0) {
                                                        $("#btnDelete").addClass("linkDisabled");
                                                        $("#btnDelete").attr("disabled", "disabled");
                                                        $("#btnDelete").die('click', Delete);
                                                        $("#btnDelete").attr("href", "#");                                                        
                                                    }
                                                    else {
                                                        $("#btnDelete").removeClass("linkDisabled");
                                                        $("#btnDelete").removeAttr("disabled");
                                                        $("#btnDelete").live('click', Delete);
                                                        $("#btnDelete").attr("href", "javascript:__doPostBack('btnDelete','')");
                                                        
                                                    }
                                                })
            //绑定表格中授权按钮事件
            $(".tableList table.list tbody tr a.openWindow").click(function() {
                var UId = $(this).attr("id");
                var url = "SystemManagement/UserCommision.aspx?UserId=" + UId + "&UserName=" + $(this).parent("td").parent("tr").children("td").eq(1).text();
                var pageTitle = "对【" + $(this).parent("td").parent("tr").children("td").eq(1).text() + "】授权";
                parent.navTab.openTab(UId, url, { title: pageTitle, isIframe: true });
                return false; //阻止事件冒泡
            })

            //绑定更新和删除按钮事件
            $("#btnAdd").click(function() {
                if ($(this).attr("disabled") != "disabled") {
                    addWindow = $("#selectedID").wBox({ title: "新增用户", requestType: "iframe", target: "EditUser.aspx?Type=add", iframeWH: { width: 420, height: 280} });
                    addWindow.showBox();
                }
                return false;
            })
            $("#btnUpdate").click(function() {
                if ($(this).attr("disabled") != "disabled") {
                    var selectId = $("#selectedID").val();
                    if (parseInt(selectId) > 0) {
                        addWindow = $("#selectedID").wBox({ title: "修改用户信息", requestType: "iframe", target: "EditUser.aspx?Type=update&UserId=" + selectId, iframeWH: { width: 420, height: 280} });
                        //alert(addWindow);
                        addWindow.showBox();
                    }
                    else {
                        $.Messager.Alert({ Title: '系统消息', Message: "请选择要修改的用户！", Icon: IconType.Warning });
                    }
                    return false;
                }
            })
           
            $("div.button").hover(function() { $(this).addClass("buttonHover"); },
                                                function() { $(this).removeClass("buttonHover"); });
            $("div.buttonActive").hover(function() { $(this).addClass("buttonActiveHover"); },
                                                function() { $(this).removeClass("buttonActiveHover"); })
        });

        
    </script>
</head>
<body style="overflow: auto;">
    <div >
        <form id="form1" runat="server"> 
         <div style=" position:absolute;width:100%; height:40px;left:0px; top:0px;">
              <div style="display: block; overflow: auto; margin-bottom: 1px; border-style: solid;
                            border-width: 0px 0 1px 0; background: url('../themes/default/images/pageHeader_bg.png') repeat-x scroll 0 0 #EBF0F5;
                            border-color: #99BBE8; width: 100%; padding: 5px 0px;">
                    <div class="searchBar" style="padding:4px 5px;">
                    <ul >
                        <li style="float: left;">
                        <span >用户名称：</span>
                        <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox>
                            </li>
                        <li style="float: left; padding-left:20px">
                            <%-- <a title="查询用户信息" rel="dlg_page1" target="dialog" href="javascript:void(0)" class="button">
                    <span>查询</span></a>--%>
                            <div class="buttonActive">
                                <div class="buttonContent">
                                    <asp:Button ID="btnSearch" CommandArgument="5" runat="server" Text="查询" ToolTip="查询角色信息" 
                                        CssClass="serverButton" onclick="btnSearch_Click"/>
                                      </div>
                            </div>
                        </li>
                        <li style="clear: both" ></li>
                    </ul>
                </div>

               </div>
          </div>
         <div style=" position:absolute;width:100%;left:0px;top:38px; height:30px;">                         
             <div class="panelBar" style="width: 100%;">
                            <ul class="toolBar">
                                <li class=""><asp:LinkButton ID="btnAdd" CommandArgument="2" runat="server" CssClass="add"><span>添加用户</span> </asp:LinkButton></li>
                                <li class="line">line</li>
                                <li class=""><asp:LinkButton ID="btnUpdate" CommandArgument="3" runat="server" CssClass="edit"><span>修改用户</span> </asp:LinkButton></li>
                                <li class="line">line</li>
                                <li class=""><asp:LinkButton ID="btnDelete" CommandArgument="4" runat="server" CssClass="delete"><span>删除用户</span> </asp:LinkButton></li>
                                <li class="line">line</li>
                                <li>
                                <asp:Button ID="btnhidDelete" runat="server" Text="" style="display:none;" onclick="btnhidDelete_Click" />
                                <input type="hidden" style="display:none;" id="selectedID" runat="server" />
                                </li>
                            </ul>
                        </div>         
         </div>   
         <div style=" position:absolute; left:0px; top:71px;width:100%">
              <div class="pageContent">
            <div class="tableList">
                <table class="list" width="100%">
                    <thead>
                        <tr>   
                            <th width="100" valign="middle">
                                对用户授权
                            </th>                         
                            <th width="100" style="cursor: pointer;" class="headerSortUp">
                               <span style="float:left">用户名称</span>
                               <span style="float:right;" class="sortIcon"></span>
                            </th>
                            <th width="250" style="cursor: pointer;">
                               <span style="float:left">用户全称</span>
                               <span style="float:right;" class="sortIcon"></span>
                            </th>       
                            <th width="100" style="cursor: pointer;">
                               <span style="float:left">用户类别</span>
                               <span style="float:right;" class="sortIcon"></span>
                            </th>                             
                            <th width="250" style="cursor: pointer;">
                               <span style="float:left">所属角色</span>
                            </th>     
                            <th style="cursor: pointer;">
                               <span style="float:left">邮件地址</span>
                                <span style="float:right;" class="sortIcon"></span>
                            </th>
                             <th style="width:0px;display:none">                                
                            </th>
                            <th style="width:0px;display:none">
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <asp:Literal ID="litUserList" runat="server"></asp:Literal>                              
                    </tbody>                    
                </table>
                </div>
            </div>
         </div> 
         </form>
    </div>
</body>
</html>